# Contributor: Sergei Lukin <sergej.lukin@gmail.com>
# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=chicken
pkgver=5.2.0
pkgrel=0
pkgdesc="R5RS and R7RS compatible scheme compiler and interpreter"
url="https://call-cc.org/"
arch="all"
license="BSD-3-Clause"
depends="gcc libc-dev $pkgname-dev $pkgname-libs"
subpackages="$pkgname-doc $pkgname-libs $pkgname-dev $pkgname-feathers::noarch"
source="https://code.call-cc.org/releases/$pkgver/$pkgname-$pkgver.tar.gz"

# secfixes:
#   4.12.0-r3:
#     - CVE-2017-6949
#   4.12.0-r2:
#     - CVE-2017-9334
#   4.11.1-r0:
#     - CVE-2016-6830
#     - CVE-2016-6831

build() {
	# chicken does not support parallel builds.
	make -j1 PLATFORM=linux PREFIX=/usr
}

check() {
	make -j1 PLATFORM=linux check
}

package() {
	# chicken does not support parallel installs.
	make -j1 PLATFORM=linux PREFIX=/usr DESTDIR="$pkgdir" install

	# Move documentation to /usr/share/doc.
	mkdir -p "$pkgdir"/usr/share/doc/
	mv "$pkgdir"/usr/share/$pkgname/doc \
		"$pkgdir"/usr/share/doc/$pkgname

	# Move license to /usr/share/licenses
	mkdir -p "$pkgdir"/usr/share/licenses/$pkgname
	mv "$pkgdir"/usr/share/doc/$pkgname/LICENSE \
		"$pkgdir"/usr/share/licenses/$pkgname/
}

feathers() {
	pkgdesc="A debugger for compiled chicken programs"
	depends="tk"

	mkdir -p "$subpkgdir"/usr/bin/ \
		"$subpkgdir"/usr/share/chicken/
	mv "$pkgdir"/usr/bin/feathers \
		"$subpkgdir"/usr/bin/
	mv "$pkgdir"/usr/share/chicken/feathers.tcl \
		"$subpkgdir"/usr/share/chicken/
}

sha512sums="0290362900a5be0004774a73756c2b0f617152004571a3e5e5bf43ea55343e694f98bf7fb328f24d4fc50cc33377b25af382b9ec9e8a790c5d873d2eaf0cc2ce  chicken-5.2.0.tar.gz"
